package org.dslintegration.metamodelmerge.handler;

import org.dslintegration.merge.wizard.MergeWizard;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.ui.handlers.HandlerUtil;

public class MergeHandler extends AbstractHandler {

	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getActiveMenuSelection(event);
		IFile file = (IFile) selection.getFirstElement();

		IPath path = file.getLocation();
		MergeWizard wizard = new MergeWizard();
		wizard.setPath(path.toPortableString());

		new WizardDialog(HandlerUtil.getActiveShell(event), wizard).open();

		return null;
	}

}
